package com.sip.stream.utils.zfy.adapter;

import android.view.ViewGroup;

import com.sip.stream.R;
import com.sip.stream.databinding.ViewholderStatusBatteryBinding;
import com.sip.stream.databinding.ViewholderStatusBinding;
import com.sip.stream.databinding.ViewholderStatusGpsBinding;
import com.sip.stream.databinding.ViewholderStatusMobileNetworkBinding;
import com.sip.stream.utils.ZFYStatusType;
import com.sip.stream.utils.zfy.holder.ZFYStatusBatteryViewHolder;
import com.sip.stream.utils.zfy.holder.ZFYStatusGPSViewHolder;
import com.sip.stream.utils.zfy.holder.ZFYStatusMobileNetWorlViewHolder;
import com.sip.stream.utils.zfy.holder.ZFYStatusViewHolder;
import com.sip.stream.utils.zfy.listener.DataBindingViewHolderClickListener;

public class ZFYStatusAdapter extends BaseDataBindingAdapter<String> {
    private static final int HOLDERTYPE_BATTERY = 11;
    private static final int HOLDERTYPE_GPS = 15;
    private static final int HOLDERTYPE_MOBILENETWORKT = 14;
    private static final int HOLDERTYPE_OTHER = 13;

    public ZFYStatusAdapter(DataBindingViewHolderClickListener<String> dataBindingViewHolderClickListener) {
        super(dataBindingViewHolderClickListener);
    }

    @Override
    public BaseDataBindingViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        if (i == 11) {
            return new ZFYStatusBatteryViewHolder(ViewholderStatusBatteryBinding.bind(viewGroup), null);
        }
        if (i == 14) {
            return new ZFYStatusMobileNetWorlViewHolder(ViewholderStatusMobileNetworkBinding.bind(viewGroup), null);
        }
        if (i == 15) {
            return new ZFYStatusGPSViewHolder(ViewholderStatusGpsBinding.bind(viewGroup), null);
        }
        return new ZFYStatusViewHolder(ViewholderStatusBinding.bind(viewGroup), null);
    }

    @Override
    public int getItemViewType(int i) {
        if (i < this.datasource.size())
        {
            String type = this.datasource.get(i);
            if (type.equals(ZFYStatusType.BATTERY)){
                return 11;
            }else if (type.equals(ZFYStatusType.GPS)) {
                return 15;
            }else if (type.equals(ZFYStatusType.MOBILENETWORKT)){
                return 14;
            }else{
                return 13;
            }
        }
        return super.getItemViewType(i);
    }
}
